~ chicken-core (master) /manual/Module (scheme inexact)


 1[[tags: manual]]
 2[[toc:]]
 3
 4== Module (scheme inexact)
 5
 6The R7RS (scheme inexact) library exports procedures which
 7are typically only useful with inexact values.
 8
 9<procedure>(exp z)</procedure><br>
10<procedure>(log z [z2])</procedure><br>
11<procedure>(sin z)</procedure><br>
12<procedure>(cos z)</procedure><br>
13<procedure>(tan z)</procedure><br>
14<procedure>(asin z)</procedure><br>
15<procedure>(acos z)</procedure><br>
16<procedure>(atan x [y])</procedure>
17
18These procedures compute the usual transcendental functions. The log procedure
19computes the natural logarithm of z (not the base ten logarithm) if a single argument is given, or the base-z2 logarithm of
20z if two arguments are given. The asin, acos, and atan procedures compute
21arcsine (sin^−1), arc-cosine (cos^−1), and arctangent (tan^−1),
22respectively. The two-argument variant of atan computes {{(angle (make-rectangular x y))}}
23 (see below), even in implementations that don’t support complex numbers.
24
25In general, the mathematical functions log, arcsine, arc-cosine, and arctangent
26are multiply defined. The value of log z is defined to be the one whose
27imaginary part lies in the range from −π (inclusive if -0.0 is distinguished,
28exclusive otherwise) to π (inclusive). The value of log 0 is mathematically
29undefined. With log defined this way, the values of sin^−1 z, cos^−1 z, and
30tan^−1 z are according to the following formulæ:
31
32 sin^−1 z = −i * log (i * z + (1 − z^2)^1/2)
33
34 cos^−1 z = π/2 − sin^−1 z
35
36 tan^−1 z = (log (1 + i * z) − log (1 − i * z)) / (2 * i)
37
38However, (log 0.0) returns -inf.0 (and (log -0.0) returns -inf.0+π*i) if the
39implementation supports infinities (and -0.0).
40
41The range of (atan x y) is as in the following table. The asterisk (*) indicates that the entry
42applies to implementations that distinguish minus zero.
43
44   y condition x condition range of result r
45   y = 0.0     x > 0.0     0.0
46 ∗ y = + 0.0   x > 0.0     + 0.0
47 ∗ y = −0.0    x > 0.0     −0.0
48   y > 0.0     x > 0.0     0.0 < r < π/2
49   y > 0.0     x = 0.0     π/2
50   y > 0.0     x < 0.0     π/2 < r < π
51   y = 0.0     x < 0       π
52 ∗ y = + 0.0   x < 0.0     π
53 ∗ y = −0.0    x < 0.0     −π
54   y < 0.0     x < 0.0     −π< r< −π/2
55   y < 0.0     x = 0.0     −π/2
56   y < 0.0     x > 0.0     −π/2 < r< 0.0
57   y = 0.0     x = 0.0     undefined
58 ∗ y = + 0.0   x = + 0.0   + 0.0
59 ∗ y = −0.0    x = + 0.0   −0.0
60 ∗ y = + 0.0   x = −0.0    π
61 ∗ y = −0.0    x = −0.0    −π
62 ∗ y = + 0.0   x = 0       π/2
63 ∗ y = −0.0    x = 0       −π/2
64
65When it is possible, these procedures
66produce a real result from a real argument.
67
68---
69Previous: [[Module (scheme eval)]]
70
71Next: [[Module (scheme lazy)]]
Trap